package com.camerareader.util;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.TextView;
import android.widget.Toast;

/**
 * Created by Administrator on 2016/11/14.
 */

public class BaseUtil {
    public static void toastShort(String msg, Context context){
        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
    }

    /**
     * 重新调整textview的compoundDrawables的大小
     *
     * @param size  新的drawable尺寸
     * @param index 调整的drawable的索引序号
     * @param view  需要调整的目标textview
     */
    public static void resizeDrawable(int size, int index, TextView view) {
        Drawable[] drawables = view.getCompoundDrawables();
        Drawable target = drawables[index];
        if (target != null) {
            target.setBounds(0, 0, size, size);
        }
        view.setCompoundDrawables(drawables[0], drawables[1], drawables[2], drawables[3]);
    }
}
